package cn.kgc.javaweb.service;

import cn.kgc.javaweb.entity.Student;
import cn.kgc.javaweb.mapper.StudentMapper;
import cn.kgc.javaweb.utils.MapperUtil;

import java.util.List;

/**
 * @author: mosin
 * @version: v1.0  2022/6/25
 */
public class StudentServiceImpl implements StudentService {
    private StudentMapper studentMapper = MapperUtil.getSqlSession().getMapper(StudentMapper.class);


    @Override
    public List<Student> findAll() {
      List<Student> students =   studentMapper.selectAll();
        return students;
    }

    @Override
    public Student findById(int id) {

       Student student =  studentMapper.selectById(id);
        return student;
    }

    @Override
    public Boolean updateStudent(Student student) {

       Integer line =  studentMapper.updateStudent(student);
        return line>0;
    }

    @Override
    public Boolean deleteById(int id) {

       Integer line =  studentMapper.deleteById(id);
        return line>0;
    }

    @Override
    public Boolean addStudent(Student student) {

       Integer line =   studentMapper.addStudent(student);
        return line>0;
    }
}
